extends layout

block content
  h2= title

  each post in posts
    div.post
      h3.post-title
        a(href="/posts/view/" + post.slug, target="_blank")
          = post.title
      div.post-abstract
        != truncate(post.content, 160)
      div.post-meta
        span.post-created 时间：
          = moment(post.created).format('YYYY-MM-DD')
        span.post-author 作者：
          = post.author.name
        span.post-category 分类：
          a(href="/posts/category/" + post.category.name, target="_blank")
            = post.category.name
        span.post-comment 评论：
          = post.comments.length || 0
        span.post-favorite 被赞：
          = post.meta.favorite || 0
        span.post-link
          a(href="/posts/view/" + post._id, target="_blank") 查看全文 
          = pageNum

  if pageCount > 1
    nav
      ul.pagination
        - var currentPage = 1
        while currentPage < pageCount
          if (currentPage === pageNum)
            li.active
              a(href="/posts?page=" + currentPage)= currentPage++
          else
            li
              a(href="/posts?page=" + currentPage)= currentPage++

block scripts
  script $(document).ready(function () { console.log('kv'); });